package com.service.atm;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.bpms.common.CommonUtil;
import com.bpms.common.JdbcWorker;
import com.bpms.common.VO;
import com.bpms.esb.IService;
/**
 * 交易 数据持久化
 * @author sinodata
 *
 */
public class Savedealinfo implements IService {

	@Override
	public VO exec(VO arg0) {
		
		JdbcWorker j=null;
		VO vv = new VO();
		try{
			j = new JdbcWorker();
			j.startTransaction();
			
			SimpleDateFormat sdf = new SimpleDateFormat();
			Date date = new Date();
			
//			Long instanceid = j.getSeqValue("cmdjb_bizid");
			VO vo = new VO();		
			vo.voType = "CM_DJB";
			
			vo.setAttr("INSTANCEID", arg0.getAttr("INSTANCEID"));// ID号
			vo.setAttr("BIZID", arg0.getAttr("BIZID")); // 流水号
			
			vo.setAttr("DEVICENO", arg0.getAttr("DEVICENO"));// 设备号 1001
			vo.setAttr("NETNUM", arg0.getAttr("NETNUM"));// 网点号  1002
			vo.setAttr("CERTNUM", arg0.getAttr("CERTNUM"));//认证码 1003
			vo.setAttr("DATETIME", arg0.getAttr("DATETIME")); // 日期时间  1004
			vo.setAttr("TRANTYPE", arg0.getAttr("BILLTYPE"));//业务类型 1005  01现金支票、02转账支票、04贷记凭证、05电汇凭证  
			vo.setAttr("LAUNCHSITE", arg0.getAttr("LAUNCHSITE"));//发起网点号 1006
			
			vo.setAttr("PAYEEBANK", arg0.getAttr("PAYEEBANK"));//收款人开户行 1007
			vo.setAttr("DRAWEEBANK", arg0.getAttr("DRAWEEBANK"));//付款人开户行 1008
			
			vo.setAttr("PAYINGMARK", arg0.getAttr("PAYINGMARK"));//收付款标志 1009
			vo.setAttr("BEARERTYPE", arg0.getAttr("BEARERTYPE"));//持票人类型 1010
			vo.setAttr("IDCARD", arg0.getAttr("IDCARD"));//身份证号码 1011
			vo.setAttr("IDNAME", arg0.getAttr("IDNAME"));//身份证姓名 1012
			vo.setAttr("ISPASSWORD", arg0.getAttr("ISPASSWORD"));//是否支付密码 1013
			vo.setAttr("SYSTEMTYPE", arg0.getAttr("SYSTEMTYPE"));//对应集中处理系统业务类型 1014
			vo.setAttr("PHONENUMBER", arg0.getAttr("PHONENUMBER"));//联系电话 1015
			vo.setAttr("ISSUEDATE", arg0.getAttr("ISSUEDATE"));//凭证日期 1016
			vo.setAttr("AMOUNT", arg0.getAttr("AMOUNT"));//金额 1017
			vo.setAttr("BILLNO", arg0.getAttr("BILLNO"));//凭证编号 1018
			vo.setAttr("QUICKMARK", arg0.getAttr("IMGDATA")); // 二维码 1019
			vo.setAttr("IMAGE1", arg0.getAttr("front_checkPath"));//票据正面影像
			vo.setAttr("IMAGE2", arg0.getAttr("back_checkPath"));//票据背面影像
			/* 10-19 增加4个 字段 */
			vo.setAttr("CHECKMARKRESULT", arg0.getAttr("CHECKMARKRESULT")); //二维码校验标志 Y通过 N未通过
			vo.setAttr("DRAWEEACCNO", arg0.getAttr("DRAWEEACCNO")); // 付款人账号(开户人账号)
			vo.setAttr("PINGZHENGHAO", arg0.getAttr("PINGZHENGHAO"));// 凭证号
			vo.setAttr("EXCHANGEBANKNO", arg0.getAttr("EXCHANGEBANKNO"));// 交换行号
			/*10-23 增加DIWENCHECK*/
			vo.setAttr("DIWENCHECK", arg0.getAttr("DIWENCHECK"));// 票据底纹是否通过 Y/N
			
			sdf.applyPattern("yyyy-MM-dd");
			String ymd = sdf.format(date);
			sdf.applyPattern("HH:mm:ss");
			String hms = sdf.format(date);
			vo.setAttr("CREATEDATE", ymd);// 日期
			vo.setAttr("CREATETIME", hms);// 时间
			vo.setAttr("FLAG", arg0.getAttr("FLAG"));
			
			j.insert(vo);
			j.commit();
			vv.setAttr("BIZID", arg0.getAttr("BIZID"));
			vv.setAttr("result", "0000");
			vv.setAttr("msg", "插入成功");
			return vv;
		}catch(Exception e){
			CommonUtil.error("Savedealinfo  error", e);
			vv.setAttr("result", "9999");
			vv.setAttr("msg", "插入错误");
			try {
				j.rollback();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			return vv;
		}
	}

}
